package cn.nfwx.tv.model;

import android.os.Parcel;
import android.os.Parcelable;
import android.text.TextUtils;

public class TvProgram implements Parcelable {

    /**
     * url : null
     * program_name : 动物世界
     * type : 2 (0、已经结束；1、正在直播；2、还没开始；)
     * time : 2018-05-07 00:34
     */
    private int program_id;
    private String url;
    private String program_name;
    private int type;
    private String time;
    private String snap;
    private boolean isPlaying;
    private boolean hasAppoint;
    private String gid;

    public TvProgram() {

    }

    protected TvProgram(Parcel in) {
        program_id = in.readInt();
        url = in.readString();
        program_name = in.readString();
        type = in.readInt();
        time = in.readString();
        snap = in.readString();
        isPlaying = in.readByte() != 0;
        hasAppoint = in.readByte() != 0;
        gid = in.readString();
    }

    public static final Creator<TvProgram> CREATOR = new Creator<TvProgram>() {
        @Override
        public TvProgram createFromParcel(Parcel in) {
            return new TvProgram(in);
        }

        @Override
        public TvProgram[] newArray(int size) {
            return new TvProgram[size];
        }
    };

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getProgram_name() {
        return program_name;
    }

    public void setProgram_name(String program_name) {
        this.program_name = program_name;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getTime() {
        return time;
    }

    public void setTime(String time) {
        this.time = time;
    }

    public boolean isPlaying() {
        return isPlaying;
    }

    public void setPlaying(boolean playing) {
        isPlaying = playing;
    }

    public String getSnap() {
        return snap;
    }

    public void setSnap(String snap) {
        this.snap = snap;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(program_id);
        dest.writeString(url);
        dest.writeString(program_name);
        dest.writeInt(type);
        dest.writeString(time);
        dest.writeString(snap);
        dest.writeByte((byte) (isPlaying ? 1 : 0));
        dest.writeByte((byte) (hasAppoint ? 1 : 0));
        dest.writeString(gid);
    }

    public int getProgram_id() {
        return program_id;
    }

    public void setProgram_id(int program_id) {
        this.program_id = program_id;
    }

    ;

    public boolean isHasAppoint() {
        return hasAppoint;
    }

    public void setHasAppoint(boolean hasAppoint) {
        this.hasAppoint = hasAppoint;
    }

    public String getGid() {
        //http://new.southtv.cn:9180/tvs1/pvr-11-06_00-09.m3u8
        if (!TextUtils.isEmpty(url)) {
            int last = url.lastIndexOf("/");
            gid = url.substring(0, last);
            last = gid.lastIndexOf("/");
            gid = gid.substring(last + 1);
        }
        return gid;
    }

    public void setGid(String gid) {
        this.gid = gid;
    }
}
